package com.chinacache.maint.workorder.entity;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.chinacache.maint.commons.entity.BaseEntity;

@Entity
@Table(name = "WO_FLOW")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Flow extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private Integer status;
	private Integer order;
	private String memo;
	private Integer audit;
	private Set<FlowFieldClass> flowFieldClasss = new LinkedHashSet<FlowFieldClass>(
			0);
	private Set<FlowFieldAttribute> flowFieldAttributes = new LinkedHashSet<FlowFieldAttribute>(
			0);
	private Set<WorkOrderStep> workOrderSteps = new LinkedHashSet<WorkOrderStep>(
			0);
	private FlowClass flowClass;

	@ManyToOne
	@JoinColumn(name = "FLOWCLASS_ID")
	public FlowClass getFlowClass() {
		return flowClass;
	}

	public void setFlowClass(FlowClass flowClass) {
		this.flowClass = flowClass;
	}

	@OneToMany(mappedBy = "flow")
	@OrderBy("id")
	public Set<FlowFieldClass> getFlowFieldClasss() {
		return flowFieldClasss;
	}

	public void setFlowFieldClasss(Set<FlowFieldClass> flowFieldClasss) {
		this.flowFieldClasss = flowFieldClasss;
	}

	@Id
	@Column(name = "FLOW_ID")
	@GeneratedValue(generator = "SEQ_RPT_USER_TO_CLASS")
	@GenericGenerator(name = "SEQ_RPT_USER_TO_CLASS", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "SEQ_RPT_USER_TO_CLASS") })
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "STATUS")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "FLOW_ORDER")
	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	@OneToMany(mappedBy = "flow")
	@OrderBy("id")
	public Set<FlowFieldAttribute> getFlowFieldAttributes() {
		return flowFieldAttributes;
	}

	public void setFlowFieldAttributes(
			Set<FlowFieldAttribute> flowFieldAttributes) {
		this.flowFieldAttributes = flowFieldAttributes;
	}

	@OneToMany(mappedBy = "flow")
	@OrderBy("id")
	public Set<WorkOrderStep> getWorkOrderSteps() {
		return workOrderSteps;
	}

	public void setWorkOrderSteps(Set<WorkOrderStep> workOrderSteps) {
		this.workOrderSteps = workOrderSteps;
	}

	@Column(name = "memo")
	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@Column(name = "FLOW_AUDIT")
	public Integer getAudit() {
		return audit;
	}

	public void setAudit(Integer audit) {
		this.audit = audit;
	}

}
